package com.smh.demo1.a37;

import com.smh.demo1.common.LogColour;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author shiminghui
 * @date 2025/5/9 19:48
 * @description: TODO
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof Bean2) {
            System.out.println(LogColour.Green("Bean后处理器 初始化前的操作执行"));
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof Bean2) {
            System.out.println(LogColour.Green("Bean后处理器 初始化后的操作执行"));
        }
        return bean;
    }
}
